import { Component, OnInit } from '@angular/core';
import { HttpService } from '../../service/http.service';
import { HttpRouterService } from '../../service/http-router.service';
import { StorageService } from '../../service/storage.service';
import { Router } from '@angular/router';
import _ from 'underscore';

@Component({
  selector: 'app-order',
  templateUrl: './order.component.html',
  styleUrls: ['./order.component.less']
})
export class OrderComponent implements OnInit {

  public step = '';

  public orderList = [];
  public orderParam = '';


  constructor(
    private _http: HttpService,
    private _router: Router,
    private _storage: StorageService,
    private _httpRouter: HttpRouterService
  ) { }

  ngOnInit() {
    this.getOrderList();
  }

  // 展示订单
  getOrderList() {
    this.orderParam = 'token=' + this._storage.getLocal('token');
    this._http.post(this._httpRouter.orderList, this.orderParam).then(res => {
      if (res.code === 1) {
        this.orderList = res.data;
      }
    });
  }

  // 跳转详情
  orderDetail(customerId) {
    this._storage.setSession('danId', customerId);
    this._router.navigate(['/attache/order-details']);
  }

}
